package com.p2p.front.async;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.p2p.front.dal.model.LoanInfo;
import com.p2p.front.dal.model.Tender;
import com.p2p.front.service.LoanInfoService;
import com.p2p.front.service.TenderReturnService;
import com.p2p.front.task.LoanTimeOpenTask;

@Service("asyncBiz")
public class AsyncBiz {
	
	private final Logger logger = LoggerFactory
			.getLogger(AsyncBiz.class);
	
	@Async
	public void asyncCreateTenderReturn(Tender tender,
			LoanInfoService loanInfoService,
			TenderReturnService tenderReturnService) {
		// 生成中标记录，生成对应期数的还款记录
		LoanInfo loanInfo = loanInfoService.getLoanInfoById(tender.getLid());
		tenderReturnService.create(tender, loanInfo);
	}
	
	@Async
	public void asyncStartAutoTendeScan(LoanTimeOpenTask loanTimeOpenTask){
		logger.info("asyncStartAutoTendeScan");
		loanTimeOpenTask.findTimeOpenLoanSchedule();
	}

}
